import java.util.Scanner;
import java.util.PriorityQueue;

public class Main {

    //第 K 小的数
    public static int x;
    public static int k;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        PriorityQueue<Integer> q = new PriorityQueue<>();
        for(int i = 1; i <= n; i++){
            String op = scan.next();
            if(op.equals("push")){
                x = scan.nextInt();
                q.add(x);
            } else if (op.equals("remove")) {
                if(q.isEmpty()){
                    System.out.println("empty");
                }else{
                    q.poll();
                }
            } else if (op.equals("min")) {
                if(q.isEmpty()){
                    System.out.println("empty");
                }else{
                    System.out.println(q.peek());
                }
            } else{
                k = scan.nextInt();
                for (int j = 0; j < k; j++) {
                    System.out.print(q.peek() + " ");
                    q.poll();
                }
                System.out.println();
            }
        }
        scan.close();
    }
}
